#include <spdlog/spdlog.h>
#include <iostream>
#include "event_bus/EventBus.h"
#include <string>

EventBus gBus;

class EventDZ:public Event
{
public:
    std::string info;
};

class ZS:public Subscriber
{
public:
    void init()
    {
        EventHandler h(shared_from_this());
        h.set_callback([](Event& event){
            EventDZ& dz_ev = dynamic_cast<EventDZ&>(event);
            std::cout << "观看到地震新闻，震级:" << dz_ev.info << std::endl;
        });
        gBus.subscribe<EventDZ>(std::move(h));
    }
};

int main()
{
    auto zs = std::make_shared<ZS>();
    zs->init();
    EventDZ dz_ev;
    dz_ev.info = "7级";
    gBus.publish<EventDZ>(dz_ev);
    return 0;
}